import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [
    vue(),
    {
      name: 'element-plus-resolver',
      resolveId(id) {
        if (id.includes('element-plus') && 
           (id.includes('globalThis-config') || 
            id.includes('use-prevent-globalThis'))) {
          return { id: path.resolve(__dirname, 'src/empty-module.js'), external: false };
        }
        return null;
      }
    }
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  define: {
    global: 'globalThis',
    'process.env': {}
  },
  build: {
    chunkSizeWarningLimit: 2000,
    outDir: 'dist',
    rollupOptions: {
      onwarn(warning, warn) {
        if (warning.code === 'MODULE_LEVEL_DIRECTIVE' || 
            (warning.code === 'UNRESOLVED_IMPORT' && 
            warning.message && 
            warning.message.includes('element-plus'))) {
          return;
        }
        warn(warning);
      }
    }
  }
}) 